home *** CD-ROM | disk | FTP | other *** search
- (*===========================================================================*)
- (* Message handling *)
- (* *)
- (* Copyright 1988, 1989, 1990, 1991 by H. Roy Engehausen. All rights *)
- (* reserved. *)
- (* *)
- (*===========================================================================*)
-
- {$UNDEF DEBUG_L1} (* Debug language selection *)
-
- {$O+}
-
- UNIT BBMESS;
-
- INTERFACE
-
- PROCEDURE send_message (message_no : BYTE);
-
- FUNCTION get_message (message_no : BYTE) : STRING;
-
- PROCEDURE substitute_line(VAR in_str : STRING);
-
- IMPLEMENTATION
-
- USES
- CRT,
- bbdummy,
- bbfssf,
- bbmdata,
- bbmem,
- bbmf,
- bbmisc5,
- bbsdata,
- bbstr,
- bbtask,
- bbtime;
-
- (*===========================================================================*)
- (* Substitute a variable *)
- (*===========================================================================*)
-
- FUNCTION substitute_var(this_one : CHAR) : STRING;
-
- VAR
- counter : WORD;
- tone : INTEGER;
- t_ptr : str_ptr;
- t_str : STRING[12];
-
- (*-------------------------------------------------------------------------*)
- (* Subroutine to count messages *)
- (*-------------------------------------------------------------------------*)
-
- PROCEDURE count_messages;
-
- VAR
- i : WORD;
- search_block : search_block_type;
-
- BEGIN;
-
- FILLCHAR(search_block, SIZEOF(search_block), #0);
- search_block.search_nok := TRUE;
-
- CASE this_one OF
- 'R' : BEGIN;
- search_block.search_type := 'R';
- search_block.search_str := active_tcb^.uid_data.user_id;
- END;
- 'r' : BEGIN;
- search_block.search_type := 'D';
- search_block.search_dt := active_tcb^.uid_data.user_l_time;
- search_block.search_above := TRUE;
- END;
- END;
-
- search_block.search_last := NIL;
- i := 0;
-
- REPEAT
- search_msg(@search_block);
- INC(i);
- IF (i MOD 10) = 0 THEN task_switch;
- UNTIL search_block.search_last = NIL;
-
- counter := i - 1;
-
- END;
-
- (*-------------------------------------------------------------------------*)
- (* Main line of substitute var *)
- (*-------------------------------------------------------------------------*)
-
- BEGIN;
-
- (*-----------------------------------------------------------------------*)
- (* *)
- (* $A - @ BBS of the current message. *)
- (* $a - Call of the originating bbs. *)
- (* $B - Type of current message (single letter) *)
- (* $b - BID of current message. *)
- (* $C - The message type (by name) *)
- (* $D - The current date. *)
- (* $E - Title of current message. *)
- (* $F - Name of the users port. *)
- (* $f - Name of the "other" gateway port. *)
- (* $G - TO of the current message. *)
- (* $g - TO "H" address of current message *)
- (* $H - Hang at end of line (suppress carriage return). *)
- (* Use at end of line only. DO NOT USE on lines that go to tnc. *)
- (* $h - Home BBS of the connected user *)
- (* $I - Sysops name. *)
- (* $J - Date from current msg header *)
- (* $j - Date from orig msg header *)
- (* $K - Time from current msg header. *)
- (* $k - Time from orig msg header. *)
- (* $L - Number of the last message in the MailBox *)
- (* $l - Date/time of user's last "L" command. *)
- (* $M - Message number from current msg header. *)
- (* $m - Message number from orig msg header. *)
- (* $N - Number of active messages. *)
- (* $n - Number of killed messages. *)
- (* $O - Sysops callsign. *)
- (* $o - Hierarchical address of this BBS *)
- (* $P - FROM from current msg header. *)
- (* $p - FROM "H" address *)
- (* $Q - Sysops QTH *)
- (* $q - Language setting for this user. *)
- (* $R - Number of messages awaiting to be read by this user (LM) *)
- (* $r - Number of messages awaiting to be listed by this user (L) *)
- (* $S - Status of current message. *)
- (* $s - Screen length of user. *)
- (* $T - The current time. *)
- (* $t - Task ID. *)
- (* $U - User callsign. *)
- (* $u - User authentication requirements *)
- (* $V - Software version. *)
- (* $W - Users name. *)
- (* $w - Screen width of user. *)
- (* $X - Date user last logged in. *)
- (* $Y - Time user last logged in. *)
- (* $Z - User's MAX PAC *)
- (* $z - User's format *)
- (* $1 - Parameter *)
- (* $7 - Tone 440 Hz *)
- (* $8 - Tone 880 Hz *)
- (* $9 - Tone 1320 Hz *)
- (* $: - Leave alone *)
- (* *)
- (*-----------------------------------------------------------------------*)
-
- WITH active_tcb^, active_tcb^.uid_data, active_tcb^.curr_msg.msg_i_mb DO
-
- CASE this_one OF
-
- 'a': substitute_var := msg_from_at;
- 'b': substitute_var := msg_bid;
- 'd': BEGIN;
- STR(msg_number, t_str);
- substitute_var := t_str;
- END;
- 'g': substitute_var := msg_to_h;
- 'h': substitute_var := user_bbs;
- 'j': substitute_var := COPY(time_str(msg_dt_orig, TRUE) , 1, 6);
- 'k': substitute_var := COPY(time_str(msg_dt_orig, FALSE), 6, 4);
- 'l': substitute_var := time_str(user_l_time, TRUE);
- 'm': BEGIN;
- STR(msg_no_orig, t_str);
- substitute_var := t_str;
- END;
- 'n': BEGIN;
- STR(msg_counter_kill, t_str);
- substitute_var := t_str;
- END;
- 'o': substitute_var := opt_block.this_bb_h;
- 'p': substitute_var := msg_from_h;
- 'q': substitute_var := user_lang;
- 'r', 'R':
- BEGIN;
- count_messages;
- STR(counter, t_str);
- substitute_var := t_str;
- END;
- 's': BEGIN;
- STR(user_scr_len, t_str);
- substitute_var := t_str;
- END;
- 't': BEGIN;
- STR(tcb_number, t_str);
- substitute_var := port_chan_s + '-' + t_str;
- END;
- 'u': substitute_var := display_access_block(user_access);
- 'w': BEGIN;
- STR(user_scr_wid, t_str);
- substitute_var := t_str;
- END;
- 'z': BEGIN;
- STR(uid_data.user_fmt, t_str);
- substitute_var := t_str;
- END;
- 'A': substitute_var := msg_to_at;
- 'B': substitute_var := msg_type;
- 'C': BEGIN;
- CASE msg_type OF
- 'P': substitute_var := get_message(message_mtype_p);
- 'A',
- 'B': substitute_var := get_message(message_mtype_b);
- 'T': substitute_var := get_message(message_mtype_t);
- 'S': substitute_var := get_message(message_mtype_s);
- ELSE
- substitute_var := get_message(message_mtype_other);
- END;
- END;
- 'D': substitute_var := COPY(todays_date_time, 1, 6);
- 'E': substitute_var := msg_subj;
- 'F': substitute_var := active_port^.port_char;
- 'G': substitute_var := msg_to;
- 'H': substitute_var := cr;
- 'I': substitute_var := opt_block.this_bb_name;
- 'J': substitute_var := COPY(time_str(msg_dt_in, TRUE), 1, 6);
- 'K': substitute_var := COPY(time_str(msg_dt_in, FALSE), 6, 4);
- 'L': BEGIN;
- STR(next_msg_no - 1, t_str);
- substitute_var := t_str;
- END;
- 'M': BEGIN;
- STR(msg_number, t_str);
- substitute_var := t_str;
- END;
- 'N': BEGIN;
- STR(msg_counter_ok, t_str);
- substitute_var := t_str;
- END;
- 'O': substitute_var := opt_block.this_bb_sign;
- 'P': substitute_var := msg_from;
- 'Q': substitute_var := opt_block.this_bb_loc;
- (* 'R' is same as 'r' *)
- 'S': substitute_var := msg_flag_char(msg_flag);
- 'T': substitute_var := SUBSTR(todays_date_time, 8, 4);
- 'U': substitute_var := user_id;
- 'V': substitute_var := '1';
- 'W': substitute_var := user_name;
- 'X': substitute_var := COPY(time_str(user_last, TRUE), 1, 6);
- 'Y': substitute_var := COPY(time_str(user_last, FALSE), 6, 4);
- 'Z': BEGIN;
- STR(uid_data.max_pac, t_str);
- substitute_var := t_str;
- END;
- '1': BEGIN;
- t_ptr := find_task_mem_addr('$1');
- IF t_ptr <> NIL THEN
- substitute_var := t_ptr^
- ELSE
- substitute_var := '';
- END;
- '7'..'9':
- BEGIN;
- substitute_var := '';
- IF active_tcb^.tcb_type <> th_user THEN
- BEGIN;
- tone := 440 * (ORD(this_one) - ORD('7') + 1);
- SOUND(tone);
- DELAY(100);
- NOSOUND;
- END;
- END;
- ':': substitute_var := '$:';
-
- ELSE
- substitute_var := this_one;
-
- END;
-
- END;
-
- (*===========================================================================*)
- (* Substitute on a line *)
- (*===========================================================================*)
-
- PROCEDURE substitute_line(VAR in_str : STRING);
-
- VAR
- i : WORD;
- temp_data : STRING;
-
- BEGIN;
-
- temp_data := '';
-
- i := POS('$', in_str);
-
- WHILE i <> 0 DO
- BEGIN;
- IF i = LENGTH(in_str) THEN
- i := 0
- ELSE
- BEGIN;
- IF i > 1 THEN
- temp_data := temp_data + COPY(in_str, 1, i-1);
- temp_data := temp_data + substitute_var(in_str[i+1]);
- in_str := COPY(in_str, i+2, 255);
- i := POS('$', in_str);
- END;
- END;
-
- IF LENGTH(in_str) > 0 THEN
- temp_data := temp_data + in_str;
-
- in_str := temp_data;
-
- END;
-
- (*===========================================================================*)
- (* Send a message to the user *)
- (*===========================================================================*)
-
- FUNCTION find_message(message_no : BYTE) : mess_list_ptr;
-
- VAR
- class_to_use : user_class_type;
- i : WORD;
- lang_to_use : BYTE;
- mess_head : mess_list_ptr;
-
- BEGIN;
-
- (*-----------------------------------------------------------------------*)
- (* What message class did we want *)
- (*-----------------------------------------------------------------------*)
-
- class_to_use := active_tcb^.uid_data.user_class;
-
- (*-----------------------------------------------------------------------*)
- (* What language did we want *)
- (*-----------------------------------------------------------------------*)
-
- lang_to_use := POS(active_tcb^.uid_data.user_lang,
- opt_block.language_list);
-
- IF lang_to_use = 0 THEN
- lang_to_use := POS(active_port^.dflt_lang,
- opt_block.language_list);
-
- IF lang_to_use <> 0 THEN
- DEC(lang_to_use);
-
- (*-----------------------------------------------------------------------*)
- (* Where is it *)
- (*-----------------------------------------------------------------------*)
-
- mess_head := message_array[message_no];
-
- (*-----------------------------------------------------------------------*)
- (* Search for message *)
- (*-----------------------------------------------------------------------*)
-
- {$IFDEF DEBUG_L1}
- WRITELN('Search for ', ORD(class_to_use), '/', lang_to_use);
- {$ENDIF}
-
- WHILE (mess_head <> NIL)
- AND ((mess_head^.mess_class > class_to_use)
- OR ((mess_head^.mess_lang <> lang_to_use)
- AND (mess_head^.mess_lang <> 0))) DO
- BEGIN;
- {$IFDEF DEBUG_L1}
- WRITELN('Skipping ', ORD(mess_head^.mess_class),
- '/', mess_head^.mess_lang);
- {$ENDIF}
- mess_head := mess_head^.mess_next;
- END;
-
- {$IFDEF DEBUG_L1}
- WRITELN('Found ', ORD(mess_head^.mess_class),
- '/', mess_head^.mess_lang);
- {$ENDIF}
-
- find_message := mess_head;
-
- END;
-
- (*===========================================================================*)
- (* Send a message to the user *)
- (*===========================================================================*)
-
- PROCEDURE send_message(message_no : BYTE);
-
- VAR
- class_to_use : user_class_type;
- lang_to_use : BYTE;
- mess_head : mess_list_ptr;
- message_line : STRING;
- message_qe : qe_ptr;
-
- (*=========================================================================*)
- (* Send a message line to the user *)
- (*=========================================================================*)
-
- PROCEDURE send_message_line;
-
- BEGIN;
-
- substitute_line(message_line);
-
- send_tnc_data_str(message_line + cr);
-
- END;
-
- (*=========================================================================*)
- (* Main line of send message *)
- (*=========================================================================*)
-
- BEGIN;
-
- (*-----------------------------------------------------------------------*)
- (* Find message *)
- (*-----------------------------------------------------------------------*)
-
- mess_head := find_message(message_no);
-
- (*-----------------------------------------------------------------------*)
- (* None found? *)
- (*-----------------------------------------------------------------------*)
-
- IF mess_head = NIL THEN
- EXIT;
-
- (*-----------------------------------------------------------------------*)
- (* Loop thru outputting message *)
- (*-----------------------------------------------------------------------*)
-
- message_qe := mess_head^.mess_this;
-
- WHILE message_qe <> NIL DO
- BEGIN;
-
- WITH message_qe^ DO
-
- BEGIN;
-
- IF NOT qe_file_type THEN
- BEGIN;
-
- message_line := qe_data;
- send_message_line;
-
- END
- ELSE
- send_file(qe_data, FALSE);
-
- message_qe := message_qe^.qe_next;
-
- END;
-
- END;
-
- (*-----------------------------------------------------------------------*)
- (* Free up any parameter list *)
- (*-----------------------------------------------------------------------*)
-
- free_task_mem('$1', TRUE);
-
- END;
-
-
- (*===========================================================================*)
- (* Get a message for a user *)
- (*===========================================================================*)
-
- FUNCTION get_message (message_no : BYTE) : STRING;
-
- VAR
- class_to_use : user_class_type;
- mess_head : mess_list_ptr;
- message_qe : qe_ptr;
- t : STRING;
-
- BEGIN;
-
- mess_head := find_message(message_no);
-
- IF mess_head = NIL THEN
- BEGIN;
- get_message := '';
- EXIT;
- END;
-
- message_qe := mess_head^.mess_this;
-
- t := message_qe^.qe_data;
-
- substitute_line(t);
-
- get_message := t;
-
- (*-----------------------------------------------------------------------*)
- (* Frre up any parameter list *)
- (*-----------------------------------------------------------------------*)
-
- free_task_mem('$1', TRUE);
-
- END;
-
- END.